import vueSetupExtend from "vite-plugin-vue-setup-extend";
import vueJsx from "@vitejs/plugin-vue-jsx";
import mockDevServerPlugin from "vite-plugin-mock-dev-server";
import type { PluginOption } from "vite";
import vue from "@vitejs/plugin-vue";
import gizp from "./gzip";
import createSvgIcon from "./svg-icon";
import createComponents from "./components";
import HtmlPlugin from "./mock";
import createAutoImport from "./auto-import";

interface Ioptions {
  root: string;
  env: any;
  isBuild: boolean;
}
export default function createVitePlugins(options: Ioptions) {
  const vitePlugins: (PluginOption | PluginOption[])[] = [
    vue(),
    vueJsx(),
    vueSetupExtend(),
    mockDevServerPlugin()
  ];

  vitePlugins.push(createComponents());
  vitePlugins.push(createAutoImport());
  vitePlugins.push(gizp());
  vitePlugins.push(createSvgIcon(options.root));
  vitePlugins.push(HtmlPlugin(options.env));

  return vitePlugins;
}
